import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:get/get.dart';

import 'index.dart';

class MarkdownPage extends GetView<MarkdownController> {
  const MarkdownPage({super.key});

  // 主视图
  Widget _buildView() {
    return Markdown(
      data: controller.markdownData(),
      imageBuilder: (Uri uri, String? title, String? alt) {
        return Image.network(uri.toString());
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<MarkdownController>(
      init: MarkdownController(),
      id: "markdown",
      builder: (_) {
        return Scaffold(
          appBar: AppBar(title: const Text("Markdown")),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
